package com;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YJ
 * Date: 2024-3-11
 * Time: 11:11
 */
public class deleteDuplicatesComplexTest {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param head ListNode类
     * @return ListNode类
     */
    public static ListNode deleteDuplicates (ListNode head) {
        // write code here
        if(head == null || head.next == null) {
            return head;
        }
        ListNode pre = new ListNode(0);
        pre.next = head;
        ListNode cur = pre;
        while(cur.next != null && cur.next.next != null) {
            if(cur.next.val == cur.next.next.val) {
                int tmp = cur.next.val;
                while(cur.next != null && cur.next.val == tmp) {
                    cur.next = cur.next.next;
                }
            } else {
                cur = cur.next;
            }
        }
        return pre.next;
    }

    public static void main(String[] args) {
        ListNode head = new ListNode(1);
        ListNode list1 = new ListNode(2);
        ListNode list2 = new ListNode(2);
        head.next = list1;
        list1.next = list2;
        deleteDuplicates(head);
        System.out.println(-1);
    }
}
